<template>
  <div id="profile">
    <div class="header">
      <div class="back" @click="goback">
        <svg
          t="1734089579125"
          class="icon"
          viewBox="0 0 1024 1024"
          version="1.1"
          xmlns="http://www.w3.org/2000/svg"
          p-id="6403"
          width="16"
          height="16"
        >
          <path
            d="M748.8 160 390.4 512l358.4 352c19.2 19.2 19.2 57.6 0 76.8-19.2 19.2-57.6 19.2-76.8 0L281.6 556.8c0 0-6.4 0-6.4-6.4C262.4 544 256 524.8 256 512c0-12.8 6.4-32 19.2-38.4 0 0 6.4 0 6.4-6.4l390.4-390.4c19.2-19.2 57.6-19.2 76.8 0C774.4 102.4 774.4 134.4 748.8 160z"
            fill="#515151"
            p-id="6404"
          ></path>
        </svg>
      </div>
      <div class="title">个人中心</div>
    </div>
    <div class="content">
      <div class="user-info">
        <div class="email">邮箱: {{ user.email }}</div>
        <div class="id">用户ID: {{ user.id }}</div>
      </div>
      <div class="logout">
        <button @click="logout">退出登录</button>
      </div>
    </div>
  </div>
</template>

<script lang="ts" setup>
import { computed } from 'vue'
import { useRouter } from 'vue-router'
import { useUserStore } from '@/stores/useUserStore'

const router = useRouter()
const userStore = useUserStore()

const user = computed(() => ({
  email: userStore.userEmail,
  id: userStore.userId,
}))

const logout = () => {
  userStore.logout()
  router.push('/login')
}

const goback = () => {
  router.go(-1)
}
</script>

<style scoped lang="less">
#profile {
  width: 100%;
  .header {
    width: 100%;
    height: 42rem;
    min-height: 42rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 14rem;
    .back {
      svg {
        width: 16rem;
        height: 16rem;
      }
    }
    .title {
      font-size: 17rem;
      color: rgb(51, 51, 51);
      font-weight: 700;
    }
  }
  .content {
    padding: 20rem 24rem;
    .user-info {
      margin-bottom: 40rem;
      .email {
        font-size: 16rem;
        margin-bottom: 10rem;
      }
      .id {
        font-size: 16rem;
      }
    }
    .logout {
      button {
        width: 100%;
        height: 48rem;
        background-color: #ff3d58;
        border-radius: 24rem;
        font-size: 16rem;
        font-weight: 500;
        color: #fff;
        line-height: 48rem;
        border: 0;
      }
    }
  }
}
</style>